package com.goalias.controller;

import com.goalias.resp.Result;
import com.goalias.service.impl.TyChatServiceImpl;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/ability/chat")
public class ChatController {
    @Resource
    private TyChatServiceImpl tyChatService;
    @PostMapping("/cheerWord")
    public Result getCheerWord() {
        String tyAccessKey = tyChatService.getAccessKey();
        if (!StringUtils.hasText(tyAccessKey)){
            return Result.error("获取accessKey失败");
        }
        String cheerWord = tyChatService.getCheerWord(tyAccessKey);
        return Result.success(cheerWord);
    }

    @PostMapping("/knowledgeWord")
    public Result getKnowledgeWord() {
        String tyAccessKey = tyChatService.getAccessKey();
        if (!StringUtils.hasText(tyAccessKey)){
            return Result.error("获取accessKey失败");
        }
        String cheerWord = tyChatService.getKnowledgeWord(tyAccessKey);
        return Result.success(cheerWord);
    }


}
